<template>
  <div class="model">
    <div class="mark" @click="changeisShowLoginModel(false)"></div>
    <div class="loginbox">
      <div class="close" @click="changeisShowLoginModel(false)"></div>
      <section class="navs">
        <a href="javascript:;" :class="{ curr: isShow }" @click="isShow = true">手机号码登录</a>
        |
        <a href="javascript:;" :class="{ curr: !isShow }" @click="isShow = false">微信扫码登录</a>
      </section>
      <div class="content">
        <div class="phonelogin" v-show="isShow">
          <div class="row">
            <input type="text" placeholder="请输入手机号" v-model.number="phoneNumber" />
          </div>
          <div class="row">
            <!-- <slide-verify
              :l="42"
              :r="20"
              :w="362"
              :h="140"
              @success="onSuccess"
              @fail="onFail"
              @refresh="onRefresh"
              :style="{ width: '100%' }"
              class="slide-box"
              ref="slideBlock"
              :slider-text="msg"
              :imgs="imgs"
            ></slide-verify> -->
          </div>
          <div class="row">
            <input type="text" placeholder="请输入短信验证码" />
            <button class="btncode btn" v-show="isShowCount">获取验证码</button>
            <button class="btncode btn" v-show="!isShowCount">{{ count }}s</button>
          </div>
          <div class="row">
            <button class="btnlogin btn">登录</button>
          </div>
        </div>
        <div class="qrlogin" v-show="!isShow">二维码</div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapMutations } from "vuex";
// import { validatePhoneNumber } from "@/Utils";
// import { sendSMSApi } from "@/request/Api.js";
export default {
  data() {
    return {
      isShow: true,
      msg: "向右滑动",
      imgs: [require("@/assets/img/integral-01.9386d4bf.png"), require("@/assets/img/integral-02.150d92a1.png"), require("@/assets/img/integral-03.9870f3f1.png")],
      phoneNumber: "",
      count: 6,
      isShowCount: true,
    };
  },
  methods: {
    ...mapMutations({
      changeisShowLoginModel: "showModel/changeisShowLoginModel",
    }),
    // // 拼图成功
    // onSuccess(times) {
    //   let ms = (times / 1000).toFixed(1);
    //   this.msg = "login success, 耗时 " + ms + "s";
    // },
    // // 拼图失败
    // onFail() {
    //   this.onRefresh(); // 重新刷新拼图
    // },
    // // 拼图刷新
    // onRefresh() {
    //   this.msg = "再试一次";
    // },
    // async getCode() {
    //   // validatePhoneNumber(this.phoneNumber) 得到的结果是true 或者 false
    //   if (!validatePhoneNumber(this.phoneNumber)) {
    //     return alert("请输入正确的手机号");
    //   }
    //   if (this.msg == "再试一次" || this.msg == "向右滑动") {
    //     return alert("请滑动滑块验证");
    //   }
    //   // let res = await sendSMSApi({ phone: this.phoneNumber });
    //   // console.log(res);
    //   // if (!res) return;
    //   // if (res.data.code == 0) {
    //   //   this.isShowCount = false;
    //   //   let timer = setInterval(() => {
    //   //     this.count--;
    //   //     if (this.count == 0) {
    //   //       clearInterval(timer);
    //   //       this.count = 6;
    //   //       this.isShowCount = true;
    //   //     }
    //   //   }, 1000);
    //   // }

    //   // alert("获取成功");
    // },
  },
};
</script>

<style lang="less" scoped>
.model {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  .mark {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
  }
  .loginbox {
    width: 555px;
    height: 423px;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    margin: auto;
    background: url("@/assets/img/login-box-bg.png");
    .close {
      width: 23px;
      height: 23px;
      position: absolute;
      top: 25px;
      right: 60px;
      background: url("@/assets/img/close.png");
    }
    .navs {
      font-size: 18px;
      padding-top: 50px;
      text-align: center;
      a {
        text-decoration: none;
        color: #ccc;
        &.curr {
          color: #333;
        }
      }
    }
    .content {
      width: 355px;
      margin: 30px auto;
      .phonelogin {
        .row {
          display: flex;
          width: 100%;
          height: 44px;
          margin-bottom: 20px;
          input {
            flex: 1;
            text-indent: 1em;
            outline: none;
          }
          .btncode {
            margin-left: 10px;
            width: 80px;
          }
          .btnlogin {
            width: 100%;
            height: 100%;
          }
          .btn {
            background-color: #0a328e;
            color: #fff;
            border: none;
          }
        }
      }
    }
  }
}
/deep/.slide-box {
  width: 100%;
  position: relative;
  box-sizing: border-box;
  canvas {
    position: absolute;
    left: 0;
    top: -120px;
    display: none;
    width: 100%;
    box-sizing: border-box;
  }
  .slide-verify-block {
    width: 85px;
    height: 136px;
  }
  .slide-verify-refresh-icon {
    top: -120px;
    display: none;
  }
  &:hover {
    canvas {
      display: block;
    }
    .slide-verify-refresh-icon {
      display: block;
    }
  }
}
</style>
